<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>中华盛世金像后台管理系统 - 注册</title>
    <link rel="shortcut icon" href="favicon.ico"> <link href="/admin/Public/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="/admin/Public/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="/admin/Public/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/admin/Public/css/animate.min.css" rel="stylesheet">
    <link href="/admin/Public/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>

</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen   animated fadeInDown">
        <div>
            <div>

                <h1 class="logo-name" style="width:300px; height:187px; background: url(/admin/Public/img/logo.png) no-repeat center center;"></h1>

            </div>
            <h3>欢迎中华盛世金像后台管理系统</h3>
            <p>创建一个新账户</p>
            <form class="m-t" role="form" action="#">
                <div class="form-group">
                    <input type="text" id="username" class="form-control" placeholder="请输入用户名" required="">
                    <span id="username_err"></span>
                </div>
                <div class="form-group">
                    <input type="password" id="password" class="form-control" placeholder="请输入密码" required="">
                    <span id="password_err"></span>
                </div>
                <div class="form-group">
                    <input type="password" id="ok_password" class="form-control" placeholder="请再次输入密码" required="">
                    <span id="ok_password_err"></span>
                </div>
                <div class="form-group text-left">
                    <div class="checkbox i-checks">
                        <label class="no-padding">
                            <input type="checkbox" id="zcxy"><i></i> 我同意注册协议<span id="qrxy"></span></label>
                    </div>
                </div>
                <button type="submit" class="btn btn-primary block full-width m-b" id="register">注 册</button>

                <p class="text-muted text-center"><small>已经有账户了？</small><a href="/admin/login">点此登录</a>
                </p>

            </form>
        </div>
    </div>
    <script src="/admin/Public/js/jquery.min.js?v=2.1.4"></script>
    <script src="/admin/Public/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="/admin/Public/js/plugins/iCheck/icheck.min.js"></script>
    <script>
        $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});
    </script>
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<script type="text/javascript">
    //用户名输入框失焦时间
    $("#username").blur(function(){
        var username = $("#username").val();
        var zz = /^[\@A-Za-z0-9]{5,18}$/;
        if(username == "" || zz.test(username) == false ){
            $("#username_err").html("用户名错误，请填写5-18位任意字母和数字").css("color", "#e60012");
            return false;
        }else{
            $("#username_err").html("用户名格式正确").css("color", "green");
        }
    })
    //密码输入框失焦时间
    $("#password").on("blur",function(){
        var username = $("#username").val();
        var password = $("#password").val();
        var zz = /^[\@A-Za-z0-9]{5,18}$/;
        if(password == "" || zz.test(password) == false ){
            $("#password_err").html("密码错误，请填写5-18位任意字母和数字").css("color", "#e60012");
            return false;
        }if(username == password){
            $("#password_err").html("密码错误，不能与用户名相同").css("color", "#e60012");
            return false;
        }else{
            $("#password_err").html("密码格式正确").css("color", "green");
        }
    });

   //确认密码输入框失焦时间
    $("#ok_password").on("blur",function(){
        var password = $("#password").val();
        var ok_password = $("#ok_password").val();
        if(password == ok_password){
            $("#ok_password_err").html("两次密码输入一致").css("color", "green");
        }if(password != ok_password){
            $("#ok_password_err").html("两次密码不一致").css("color", "#e60012");
            return false;
        }
    });

    $('#register').on('click', function(){
        var username = $("#username").val();
        var password = $("#password").val();
        var ok_password = $("#ok_password").val();
        var register = $("#register").val();

        if($("#zcxy").is(':checked') == false){
            $("#qrxy").html("请确认注册协议").css("color", "#e60012");
            return;
        }
        $.ajax({
            type: "POST",
            url: "/admin/login/register",
            data : {
                    username:username,
                    password:password,
                    ok_password:ok_password,
                    register:register,
                },
            success: function(data) {
                var data = jQuery.parseJSON(data);
                if(data == "100"){
                    window.location = "/admin/login/index";
                }
                // if(data.err_1 == 1){
                //     $("#username_err").html("用户名格式正确").css("color", "green");
                // }if(data.err_1 == 2){
                //     $("#username_err").html("用户名错误，请填写5-18位任意字母和数字").css("color", "#e60012");
                // }
                // if(data.err_2 == 1){
                //     $("#password_err").html("密码错误，不能与用户名相同").css("color", "#e60012");
                // }
                // if(data.err_3 == 1){
                //     $("#password_err").html("密码格式正确").css("color", "green");
                // }if(data.err_3 == 2){
                //     $("#password_err").html("密码错误，请填写5-18位任意字母和数字").css("color", "#e60012");
                // }
                // if(data.err_4 == 1){
                //     $("#ok_password_err").html("两次密码输入一致").css("color", "green");
                // }if(data.err_4 == 2){
                //     $("#ok_password_err").html("两次密码不一致").css("color", "#e60012");
                // }

            },
        });
        return false;
    })
</script>

</body>
</html>
